package timing.ukulele.seal.receiver;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import timing.ukulele.seal.persistent.Seal;
import timing.ukulele.seal.service.SealService;

import static timing.ukulele.seal.config.TopicConfig.SEAL_CROP_ROUTING;


@Component
@Slf4j
public class SealCropReceiver {

    private final SealService service;

    public SealCropReceiver(SealService service) {
        this.service = service;
    }

    @RabbitHandler
    @RabbitListener(queues = SEAL_CROP_ROUTING)
    public void sealCropMessage(Seal seal) {
        this.service.setCropSeal(seal);
    }
}
